from flask import Flask
from jinja2 import Markup
from pyecharts import options as opts
from pyecharts.charts import Bar
from config import config


app = Flask(__name__)


def bar_base() -> Bar:
    c = (
        Bar()
        .add_xaxis(config.DATA)
        .add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
        .add_yaxis("商家B", [15, 25, 16, 55, 48, 8])
        .set_global_opts(title_opts=opts.TitleOpts(title='示例', subtitle='副标题'))
    )
    return c


@app.route('/')
def index():
    c = bar_base()
    return Markup(c.render_embed())


if __name__ == '__main__':
    app.run()
